package com.hxzy.module.admin.api;

import com.github.pagehelper.PageInfo;
import com.hxzy.framework.common.resp.R;
import com.hxzy.module.admin.api.account.req.AccountListReq;
import com.hxzy.module.admin.api.account.resp.AdminAccountListResp;
import com.hxzy.module.admin.api.account.resp.LoadUserResp;
import com.hxzy.module.admin.api.enums.ApiConstants;
import com.hxzy.module.admin.api.fallback.AdminFeignApiFallbackFactory;
import com.hxzy.module.admin.api.role.req.*;
import com.hxzy.module.admin.api.role.resp.AdminRoleResp;
import com.hxzy.module.admin.api.role.resp.RoleAuthorityTreeResp;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author wy
 * @Description TODO
 * @Date 2024/1/28 15:15
 * @Version 1.0
 */
@FeignClient(name = ApiConstants.SERVER_NAME,fallbackFactory = AdminFeignApiFallbackFactory.class)
public interface AdminFeignApi {


    /**
     * 获取当前用户信息(登录后菜单权限)
     * @param accountId
     * @return
     */
    @GetMapping(value = "/ums/loadUser/{accountId}")
    R<LoadUserResp> adminAccountLoadUser(@PathVariable(value = "accountId") Long accountId);

    /**
     * 获取商家角色列表
     * @param req
     * @return
     */
    @GetMapping(value = "/ums/roleList")
    R<PageInfo<AdminRoleResp>> adminRoleList(@SpringQueryMap AdminRoleReq req);

    /**
     * 角色详情
     * @param roleId
     * @return
     */
    @GetMapping(value = "/ums/roleDetail/{roleId}")
    R<AdminRoleResp> adminRoleDetail(@PathVariable(value = "roleId") Long roleId);

    /**
     * 根据角色id返回权限树
     * @param roleId
     * @return
     */
    @GetMapping(value = "/ums/roleAuthorityTree/{roleId}")
    R<List<RoleAuthorityTreeResp>> roleAuthorityTree(@PathVariable(value = "roleId") Long roleId);

    /**
     * 新增角色
     * @param req
     * @return
     */
    @PostMapping(value = "/ums/addRole")
    R addRole(@RequestBody AdminRoleAddReq req);

    /**
     * 编辑角色
     * @param req
     * @return
     */
    @PutMapping(value = "/ums/editRole")
    R editRole(@RequestBody AdminRoleEditReq req);

    /**
     * 修改角色权限
     * @param req
     * @return
     */
    @PutMapping(value = "/ums/changeRoleAuthority")
    R changeRoleAuthority(@RequestBody ChangeRoleAuthorityReq req);

    /**
     * 修改角色状态
     * @param req
     * @return
     */
    @PutMapping(value = "/ums/changeRoleState")
    R changeRoleState(@RequestBody ChangeRoleStateReq req);


    /**
     * 删除角色信息
     * @param roleId
     * @return
     */
    @DeleteMapping(value = "/ums/delRole/{roleId}")
    R  delRole(@PathVariable(value = "roleId") Long roleId);


    /**
     * 帐号列表
     * @param req
     * @return
     */
    @GetMapping(value = "/ums/accountList")
    R<PageInfo<AdminAccountListResp>> accountList(@SpringQueryMap AccountListReq req);
}
